<extend name="./Application/Admin/View/Public/base.html" />
<block name="eosi-css">
    <link href="__PUBLIC__/assets/css/daterangepicker.css" rel="stylesheet">
</block>
<block name="eosi-js"> <script
    src="__PUBLIC__/assets/js/date-time/bootstrap-datepicker.min.js"></script>
    <script src="__PUBLIC__/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
    <script src="__PUBLIC__/assets/js/jqGrid/i18n/grid.locale-en.js"></script>
    <script type="text/javascript">
        var $path_base = "/"; //this will be used in gritter alerts containing images
    </script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/datepicker/daterangepicker-bs3.css" />
    <script type="text/javascript" src="__PUBLIC__/datepicker/moment.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/datepicker/daterangepicker.min.js"></script>

</block>
<block name="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div style="padding-bottom:5px;">
                <!--  <div style="padding-bottom:5px;">
                   <button class="btn btn-primary btn-xs" onclick="location.href = '{:U('addUser')}?type=1'">添加新用户</button>
               </div> -->
                呢称 <input type="text" id="nickname" value="{$nickname}" namne="nickname" style="width:100px">
                姓名 <input type="text" id="realname" value="{$realname}" namne="realname" style="width:100px">
                电话 <input type="text" id="phone" value="{$phone}" namne="phone">
                创建时间   <input type="text" name="create_time" value="{$create_time}" id="create_time" style="width: 280px;"><br><br>
                排序选择 <select name="order_type" id="order_type">
                    <option value="time" <neq name="order" value="user">selected="selected"</neq>> 时间倒序 </option>
                    <option value="user" <eq name="order" value="user">selected="selected"</eq>> 助力好友倒序 </option>       
                </select>
                疤痕时间<select name="ba_time_str" id="ba_time_str">
                    <option value=""> 请选择... </option> 
                    <option value="1" <eq name="ba_time_str" value="1">selected="selected"</eq>> 6个月内 </option>
                    <option value="2" <eq name="ba_time_str" value="2">selected="selected"</eq>> 6-12个月 </option>
                    <option value="3" <eq name="ba_time_str" value="3">selected="selected"</eq>> 1年-2年 </option>
                    <option value="4" <eq name="ba_time_str" value="4">selected="selected"</eq>> 2年以上 </option>
                </select>
                <input type="button" class="btn btn-primary btn-xs" name="submit" id="cx" value="查询">  
                 &nbsp;&nbsp;<input type="button" class="btn btn-primary btn-xs"  id="export" value="导出列表"> 
                <!-- &nbsp;&nbsp;<input type="button" class="btn btn-primary btn-xs"  id="export" value="导出EXCLE">  -->
            </div>

            <table class="table table-striped table-bordered table-hover">
                <thead>

                    <tr>
                        <th>ID</th>
                        <th>呢称</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>联系电话</th>
                        <th>疤痕时间</th>
                        <th>创建时间</th>
                        <th>助力好友数</th>
                        <th>是否中奖  中奖日期</th>
                        <th>领取券数</th>
                        <th>地址</th>

                    </tr>
                </thead>
                <tbody>
                <volist name="user" id="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.nickname}</td>
                        <td>{$vo.realname}</td>
                    <if condition="$vo.sex eq 1">
                        <td>男</td>
                        <else/>
                        <td>女</td>
                    </if>
                    <td>{$vo.phone}</td>
                    <td>{$vo.ba_time_str}</td>


                    <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                    <td>{$vo.help_friend_count}</td>
               
                    <td>
                        <label>
                            <input id="check_winner{$vo.id}" type='checkbox' class='ace ace-switch ace-switch-6' name='switch-field-1' <if condition="$vo.is_winner egt 1">checked</if>  onchange="zhongjiang({$vo.id},{$vo.is_winner},this)">
                            <span class='lbl'></span>
                            <select name="winner_riqi" id="winner_riqi_{$vo.id}">
                                <option value="0"> 选择中奖日期 </option> 
                                <option value="2015-10-12" <eq name="vo.batch" value="2015-10-12">selected="selected"</eq>> 10月12 </option>
                                <option value="2015-10-13" <eq name="vo.batch" value="2015-10-13">selected="selected"</eq>> 10月13 </option>
                                <option value="2015-10-14" <eq name="vo.batch" value="2015-10-14">selected="selected"</eq>> 10月14 </option>
                                <option value="2015-10-15" <eq name="vo.batch" value="2015-10-15">selected="selected"</eq>> 10月15 </option>
                                <option value="2015-10-16" <eq name="vo.batch" value="2015-10-16">selected="selected"</eq>> 10月16 </option>
                                <option value="2015-10-17" <eq name="vo.batch" value="2015-10-17">selected="selected"</eq>> 10月17 </option>
                                <option value="2015-10-18" <eq name="vo.batch" value="2015-10-18">selected="selected"</eq>> 10月18 </option>
                                <option value="2015-10-19" <eq name="vo.batch" value="2015-10-19">selected="selected"</eq>> 10月19 </option>
                                <option value="2015-10-20" <eq name="vo.batch" value="2015-10-20">selected="selected"</eq>> 10月20 </option>
                                <option value="2015-10-21" <eq name="vo.batch" value="2015-10-21">selected="selected"</eq>> 10月21 </option>
                            </select>
                        </label>
                    </td>
                    <td>{$vo.cart_count}</td>
                    <td>{$vo.address}</td>
                    </tr>
                </volist>
                </tbody>
            </table>
            <div class="pager">{$page}</div>
        </div>
    </div><!-- /.row -->
    <script>
        function zhongjiang(id, is_winner,obj) {
            var riqi=$("#winner_riqi_"+id).val();
            if((riqi==0)&&(is_winner==0)){
                alert('请先选择中奖日期');
                $('#check_winner'+id).attr("checked",false);
                return;
            }
            //$riqiText=$("#winner_riqi_"+id+" option:selected").text();
            $.ajax({
                type: 'post',
                data: 'id=' + id + '&is_winner=' + is_winner+'&riqi='+riqi,
                dataType: 'json',
                url: '__CONTROLLER__/setWinner',
                success: function(msg) {
                    art.dialog.alert(msg, function() {
                        location.reload();
                    });
                }
            })
        }
    </script>

    <script type="text/javascript">
        $(function() {

            $('#create_time').daterangepicker(
                    {
                        timePicker: true,
                        timePicker12Hour: false,
                        timePickerIncrement: 60,
                        format: 'YYYY-MM-DD HH:00:00',
                        startDate: moment(),
                        endDate: moment(),
                        separator: '~',
                    },
                    function(start, end, label) {
                        //回调
                    });

            //下拉答案改变事件
            $('#province_id').change(function() {
                var pcode = $(this).children('option:selected').val();
                var str = '';
                var str2 = '';
                $.ajax({
                    type: "post",
                    url: "__CONTROLLER__/getCity",
                    data: "pcode=" + pcode,
                    dataType: 'json',
                    success: function(data) {


                        str += "<option value=''>请选城市</option>";
                        for (i = 0; i < data.data.length; i++) {

                            str += "<option value='" + data.data[i]['code'] + "'>" + data.data[i]['name'] + "</option>";
                        }

                        $('#city_id').html(str);

                    }
                })

            })


            //提交表单

            $('#cx').click(function() {
                var myDate = new Date();
                var mytime = myDate.getSeconds() + 's' + myDate.getMilliseconds();

                var nickname = $('#nickname').val();
                var realname = $('#realname').val();
                var phone = $('#phone').val();
                var create_time = $('#create_time').val();
                var order_type = $('#order_type').val();
                var ba_time_str = $('#ba_time_str').val();
                //var award=$('#award').val();
                if (nickname != '') {
                    nickname = '/nickname/' + nickname;
                }
                if (realname != '') {
                    realname = '/realname/' + realname;
                }
                if (phone != '') {
                    phone = '/phone/' + phone;
                }
                if (create_time != '') {
                    create_time = '/create_time/' + create_time;
                }
                if (order_type != '') {
                    order_type = '/order_type/' + order_type
                }
                 if (ba_time_str != '') {
                    ba_time_str = '/ba_time_str/' + ba_time_str
                }

                /* if(award !=''){
                 award = '/award/'+award;
                 } */


                location.href = "__CONTROLLER__/index" + nickname + realname + phone + create_time + order_type +ba_time_str+ '?tips=' + mytime;

            })

        })

        $('#export').click(function() {

            var name = $('#name').val();
            var mobile = $('#mobile').val();
            var province = $('#province').children('option:selected').val();
            var city = $('#city').children('option:selected').val();
            var create_time = $('#create_time').val();
             var order_type = $('#order_type').val();
                var ba_time_str = $('#ba_time_str').val();

            if (name != '') {
                name = '/name/' + name;
            }
            if (mobile != '') {
                mobile = '/mobile/' + mobile;
            }
            if (province != '') {
                province = '/province/' + province;
            }

            if (city != '') {
                city = '/q_create_time/' + city;
            }

            if (create_time != '') {
                create_time = '/create_time/' + create_time;
            }
                    if (order_type != '') {
                    order_type = '/order_type/' + order_type
                }
                 if (ba_time_str != '') {
                    ba_time_str = '/ba_time_str/' + ba_time_str
                }


            location.href = "__CONTROLLER__/export_user" + name + mobile + province + city + create_time+order_type+ba_time_str;

        })

        //编辑用户
        function editUser(userid) {
            location.href = "__CONTROLLER__/editUser/id/" + userid;
        }
    </script>
</block>